if (page == "homeContent") {
  var frameDuration = 3000;
  var currentHeaderToFade = 1;
  function fadeNextHeader() {
    $('#bandeau' + currentHeaderToFade).fadeIn(frameDuration);
    currentHeaderToFade++;
    setTimeout(fadeNextHeader, frameDuration);
  }
}

/**
 * Executed as soon as DOM is ready.
 */
$(document).ready(function() {
  allFrames = $('.slideshowImageWrapper');
  var windowWidth = $(window).width();
  if (windowWidth < 600) {
    $('#slideshowWrapper2').width(windowWidth * 0.9);
    $('#slideshowWrapper2').height(
        $('#slideshowWrapper2').width());
  }
  if (page == "homeContent") {
    fadeNextHeader();
  }
  setTimeout(nextFrame, slideshowInterval);
  slideshow2 = new Slideshow();
  slideshow2.initSlideshow("#slideshowWrapper2");
  slideshow2FrameCount = slideshow2.listBigs.find('li').length;
  setTimeout (nextFrameSlideshow2, slideshowInterval * 2);
  launchNewsSwiper();
});
var slideshow2;
var slideshowInterval = 4000;
var currentFrameSlideshow = 0;
var slideshow2FrameCount = 0;
var allFrames;

/**
 * Next Frane for the old slideshow which fade in, fadeout.
 */
function nextFrame() {
  allFrames.eq(currentFrameSlideshow).fadeOut(function() {
    currentFrameSlideshow = (currentFrameSlideshow == allFrames.length - 1) ?
        0 : currentFrameSlideshow + 1;
    allFrames.eq(currentFrameSlideshow).fadeIn();
  });
  setTimeout(nextFrame, slideshowInterval);
}

/**
 * 
 */
function nextFrameSlideshow2() {
  if (slideshow2.myBigScroll.currPageX == slideshow2FrameCount - 1) {
    slideshow2.myBigScroll.scrollTo(0);
    slideshow2.myBigScroll.currPageX = 0;
    slideshow2.scrollEndCallback();
  } else {
    slideshow2.myBigScroll.scrollToPage("next");
  }
  setTimeout (nextFrameSlideshow2, slideshowInterval);
}

/**
 * Launches the news swiper.
 */
function launchNewsSwiper() {
  var mySwipeEl = $('#mySwipe');
  var numberOfslide = mySwipeEl.find('.swipe-wrap> div').length;
  window.mySwipe = Swipe(mySwipeEl.get(0), {
    // startSlide: 4,
    // auto: 3000,
       continuous: false,
    // disableScroll: true,
    // stopPropagation: true,
       callback: function(index, element) {
         if (index == 0) {
           $('.newsArrowLeft').fadeOut();
         } else {
           $('.newsArrowLeft').fadeIn();
         }
         if (index == numberOfslide - 1) {
           $('.newsArrowRight').fadeOut();
         } else {
           $('.newsArrowRight').fadeIn();
         }
       },
    // transitionEnd: function(index, element) {}
  });
}
